package com.ms.service.module.fish.message.server;

import java.nio.ByteBuffer;

import com.ms.service.module.fish.db.UsrGameLog;
import com.ms.service.module.fish.game.GameConf;
import com.ms.service.module.fish.game.GameUser;
import com.ms.service.module.fish.message.FishBaseMessage;

/**
 * 捕鱼202
 * @author cuiwm
 */
public class CatchMessage extends FishBaseMessage {
	
    private UsrGameLog log;
    private int bullet;
    private GameUser gameUser;
    
    public CatchMessage(UsrGameLog log,int bullet,GameUser gameUser) {
    	this.setLog(log);
    	this.setBullet(bullet);
    	this.gameUser = gameUser;
	}

	public UsrGameLog getLog() {
		return log;
	}

	public void setLog(UsrGameLog log) {
		this.log = log;
	}

	public int getBullet() {
		return bullet;
	}

	public void setBullet(int bullet) {
		this.bullet = bullet;
	}

	public void writeBody(ByteBuffer buf) {
		writeString(buf, log.getUid().toString());
		buf.put((byte) bullet);
		buf.putInt(log.getScriptId());
		buf.putInt(log.getAddCoin());
		buf.putInt(log.getRate());
		buf.putInt(log.orate());
		buf.putInt(log.yrate());
		
		if(gameUser == null) {
			buf.put((byte) 0);
			buf.putInt(0);
			buf.put((byte) 0);
		}else {
			buf.put((byte) gameUser.getLastShell());
			buf.putInt(GameConf.getSpecialBullet(gameUser.getLastShell()).getLimitTime());
			buf.put((byte) gameUser.getLastShellNum());
		}
	}


}